{% extends 'generic/object_detail.html' %}
{% load buttons %}
{% load helpers %}


{% block buttons %}
        {% if perms.extras.add_customfield %}
            {% clone_button object %}
        {% endif %}
        {% if perms.extras.change_customfield %}
            {% edit_button object key="name" %}
        {% endif %}
        {% if perms.extras.delete_customfield %}
            {% delete_button object key="name" %}
        {% endif %}
{% endblock buttons %}

{% block content_left_page %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Custom Field</strong>
                </div>
                <table class="table table-hover panel-body attr-table">
                    <tr>
                        <td>Slug</td>
                        <td><span>{{ object.name }}</span></td>
                    </tr>
                    <tr>
                        <td>Type</td>
                        <td><span>{{ object.type | capfirst }}</span></td>
                    </tr>
                    <tr>
                        <td>Weight</td>
                        <td><span>{{ object.weight }}</span></td>
                    </tr>
                    <tr>
                        <td>Label</td>
                        <td><span>{{ object.label | placeholder }}</span></td>
                    </tr>
                    <tr>
                        <td>Description</td>
                        <td><span>{{ object.description | render_markdown | placeholder }}</span></td>
                    </tr>
                    <tr>
                        <td>Required</td>
                        <td>
                            {% if object.required %}
                                <span class="text-success"><i class="mdi mdi-check-bold"></i></span>
                            {% else %}
                                <span class="text-danger"><i class="mdi mdi-close"></i></span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Default</td>
                        <td><span>{{ object.default }}</span></td>
                    </tr>
                    <tr>
                        <td>Filter Logic</td>
                        <td><span>{{ object.filter_logic | capfirst }}</span></td>
                    </tr>
                </table>
            </div>
            {% if object.choices.exists %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Custom Field Choices</strong>
                </div>
                <table class="table table-hover panel-body attr-table">
                    <thead>
                        <tr>
                            <th>Value</th>
                            <th>Weight</th>
                        </tr>
                    </thead>
                    <tbody>
                    {% for choice in object.choices.all %}
                        <tr>
                            <td>{{ choice.value }}</td>
                            <td>{{ choice.weight }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
            {% endif %}
{% endblock content_left_page %}

{% block content_right_page %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Assignment</strong>
                </div>
                <table class="table table-hover panel-body attr-table">
                    <tr>
                        <td>Content Types</td>
                        <td>
                            <ul>
                                {% for ct in object.content_types.all %}
                                    <li>{{ ct }}</li>
                                {% endfor %}
                            </ul>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Validation Rules</strong>
                </div>
                <table class="table table-hover panel-body attr-table">
                    <tr>
                        <td>Minimum Value</td>
                        <td><span>{{ object.validation_minimum | placeholder }}</span></td>
                    </tr>
                    <tr>
                        <td>Maximum Value Type</td>
                        <td><span>{{ object.validation_maximum | placeholder }}</span></td>
                    </tr>
                    <tr>
                        <td>Validation Regex</td>
                        <td>
                            {% if object.validation_regex %}
                                <code>{{ object.validation_regex | placeholder }}</code>
                            {% else %}
                                <span>{{ object.validation_regex | placeholder }}</span>
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>
{% endblock content_right_page %}
